package com.GlobalPaint.app.Adapter;

import android.support.v7.widget.RecyclerView;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;
import android.widget.TextView;

import com.GlobalPaint.app.R;

import butterknife.BindView;
import butterknife.ButterKnife;

/**
 * Created by Administrator on 2017/3/15 0015.
 */

public class NewHomeAdapter extends RecyclerView.Adapter<NewHomeAdapter.ViewHolder> implements View.OnClickListener {

  /*  private List<Schooldtbean> lists;*/

    @Override
    public void onClick(View view) {
        if (mOnItemClickListener != null) {
            //注意这里使用getTag方法获取数据
            mOnItemClickListener.onItemClick(view, (Integer) view.getTag());
        }
    }

    public static interface OnRecyclerViewItemClickListener {
        void onItemClick(View view, int position);
    }
    private OnRecyclerViewItemClickListener mOnItemClickListener = null;
    public void setOnItemClickListener(OnRecyclerViewItemClickListener listener) {
        this.mOnItemClickListener = listener;
    }
   /* public NewHomeAdapter(List<Schooldtbean> list) {

        lists = list;
    }*/

    @Override
    public ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
        View view = LayoutInflater.from(parent.getContext()).inflate(R.layout.home_listview1, parent, false);
        ViewHolder holder = new ViewHolder(view);
        view.setOnClickListener(this);
        return holder;
    }

    @Override
    public void onBindViewHolder(final ViewHolder holder, final int position) {
      /*  holder.itemView.setTag(position);
        holder.tvTitle.setText(lists.get(position).getBt());
        holder.tvTime.setText(CommUtility. getDateFormatLong(lists.get(position).getCreateTime(), "yyyy-MM-dd"));
        holder.tvSource.setText(lists.get(position).getDeptName() );*/

       /* if (lists.get(position).getTp() != null) {

            String strings = lists.get(position).getTp();
            String[] strs=strings.split("\\|");
                String ddd="http://ras-public.oss-cn-shanghai.aliyuncs.com/xydt/"+strs[0].toString()+".jpg";
                Picasso.with(App.context).load(ddd)
                        .into(holder.ivIcon);

        }else {
            holder.ivIcon.setImageResource(R.drawable.morf_tu);
        }*/

    }

    @Override
    public int getItemCount() {
      //  return lists.size();
        return 10;
    }

    class ViewHolder extends RecyclerView.ViewHolder {
        @BindView(R.id.tv_title)
        TextView tvTitle;
        @BindView(R.id.tv_source)
        TextView tvSource;
        @BindView(R.id.tv_time)
        TextView tvTime;
        @BindView(R.id.iv_icon)
        ImageView ivIcon;
        public ViewHolder(View itemView) {
            super(itemView);
            ButterKnife.bind(this,itemView);
        }
    }
}
